package com.example.objectprovider.service;

import org.springframework.beans.factory.ObjectProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class LoginCheckService {
    private ILoginService loginService;

//    @Autowired
//    public LoginCheckService(ILoginService loginService) {
//        this.loginService = loginService;
//    }

    public LoginCheckService(ObjectProvider<ILoginService[]> services) {
        // 1. 此处的ms就包裹了M1和M2，ms具有一系列方法获取M的实现对象，可以灵活的选取其中的符合要求的bean来进行注入
        // 2. mybatis中对于插件的注入就是使用这种方式（MybatisAutoConfiguration类），批量获取插件然后注入
        for (ILoginService[] service : services) {
            System.out.println();
        }
        ILoginService[] ifAvailable = services.getIfAvailable();
        System.out.println();
//        this.loginService = loginService;
    }

    public String loginCheck() {
        return loginService.login();
    }
}
